package com.nf.service;

import com.nf.mapper.Order;
import com.nf.mapper.OrderMapper;
import org.apache.ibatis.io.Resources;
import org.apache.ibatis.session.SqlSession;
import org.apache.ibatis.session.SqlSessionFactory;
import org.apache.ibatis.session.SqlSessionFactoryBuilder;

import java.io.IOException;
import java.io.InputStream;
import java.util.List;

public class Orderservicelmpl implements Orderservice {

    private OrderMapper orderMapper;
    private OrderMapper join=null;
    public Order test() {
        SqlSession session=null;
        try {
            InputStream inputStream = Resources.getResourceAsStream("mybaties_config.xml");
            SqlSessionFactoryBuilder builder = new SqlSessionFactoryBuilder();
            SqlSessionFactory sessionFactory = builder.build(inputStream);
            SqlSession sqlSession = sessionFactory.openSession();
            join = sqlSession.getMapper(OrderMapper.class);
        } catch (IOException e) {
            e.printStackTrace();
        } return null;
    }
    public  void  test1(){
        test();
        List<Order> list = join.findOrderById();
        for (Order order:list){
            System.out.println(order.getDetail_name());
            System.out.println(order.getOrder_id());
            System.out.println(order.getOrder_name());
            System.out.println(order.getOrder_number());
            System.out.println(order.getOrder_price());
        }
    }
}
